let myAddFunc: (num1: number, num2: number) => number = // 声明函数类型，并非箭头函数
  function(x: number, y: number): number {
    return x + y;
  }

console.log(myAddFunc(10, 20));

function sayName(firstName: string, lastName?: string): void {
  if(lastName) {
    console.log('Hello, ' + firstName + ' ' + lastName);
  } else {
    console.log('Hello, ' + firstName);
  }
}

sayName('Jack');
sayName('Mary', 'Adams');

function sayHello(name = 'EveryOne'): void {
  console.log('Hello ' + name);
}

sayHello();
sayHello('Jack');

function sayFriends(name: string, ...friends: string[]): void {
  console.log('My name is ' + name);
  console.log('My friends are : ' + friends.join(', '));
}

sayFriends('Mary', 'Jack', 'Bob', 'Lucy');
